<?php

declare(strict_types=1);

namespace sheep\library\uploader\driver;

use League\Flysystem\FilesystemAdapter;
use Overtrue\Flysystem\Cos\CosAdapter;
use think\filesystem\Driver;

class Qcloud extends Driver
{

    protected function createAdapter(): FilesystemAdapter
    {
        $config = [
            'app_id'      => $this->config['appId'], // 域名中数字部分
            'secret_id'   => $this->config['secretId'],
            'secret_key'  => $this->config['secretKey'],

            'region'      => $this->config['region'],
            'bucket'          => $this->config['bucket'],
            'cdn'             => $this->config['cdn'],
            'signed_url'   => $this->config['signed_url'] ?? false,
        ];

        return new CosAdapter($config);
    }
}
